//
//  SISSRegistSuccessViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2019/10/31.
//  Copyright © 2019 优房网. All rights reserved.
//

#import "SISSRegistSuccessViewController.h"

@interface SISSRegistSuccessViewController ()

@property (weak, nonatomic) UIView *topView;
@property (weak, nonatomic) UIImageView *topImageView;
@property (weak, nonatomic) UILabel *successLabel;
@property (weak, nonatomic) UILabel *tipLabel;

@end

@implementation SISSRegistSuccessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 添加左侧的返回按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
}

- (void)back {
    if (self.isRegistration) {
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    } else if (self.isCooperation) {
        [self.navigationController popViewControllerAnimated:YES];
    } else {
        [self backReccommend];
    }
}

- (void)backReccommend {
    
}

- (void)setTipStr:(NSString *)tipStr {
    _tipStr = tipStr;
    self.tipLabel.text = tipStr;
}

#pragma mark - UITableViewDelegate & UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuseID = @"ddd";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID];
    if ( !cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseID];
    }
    return cell;
}


- (void)setupSubviews {
    [super setupSubviews];
    
    UIView *topView = [[UIView alloc] init];
    topView.backgroundColor = UIColor.groupTableViewBackgroundColor;
    [self.view addSubview:topView];
    self.topView = topView;
    
    UIImageView *topImageView = [[UIImageView alloc] init];
    topImageView.image = [UIImage imageNamed:@"KPI_success"];
    [self.topView addSubview:topImageView];
    self.topImageView = topImageView;
    // 399CFE
    UILabel *successLabel = [UILabel yyr_labelWithText:@"登记完成" fontSize:28 textColor:MAIN_COLOR alignment:NSTextAlignmentCenter];
    [self.topView addSubview:successLabel];
    self.successLabel = successLabel;
    
    UILabel *tipLabel = [UILabel yyr_labelWithText:@"" fontSize:16 textColor:SECONDARY_TEXT_COLOR];
    [self.topView addSubview:tipLabel];
    self.tipLabel = tipLabel;
    
    SISSBaseTableView *tableView = [[SISSBaseTableView alloc] init];
    tableView.estimatedRowHeight = 44;
    tableView.rowHeight = UITableViewAutomaticDimension;
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"ddd"];
    [self.view addSubview:tableView];
    self.tableView = tableView;
    
}

- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.mas_topLayoutGuideBottom);
        make.left.right.equalTo(weakSelf.view);
    }];
    
    [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.topView).offset(2 * margin);
        make.centerX.equalTo(weakSelf.topView);
        make.size.mas_equalTo(CGSizeMake(44, 44));
    }];
    
    [self.successLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.topImageView.mas_bottom).offset(2 * margin);
        make.centerX.equalTo(weakSelf.topView);
    }];
    
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.successLabel.mas_bottom).offset(2 * margin);
        make.left.equalTo(weakSelf.topView).offset(3 * margin);
        make.right.equalTo(weakSelf.topView).offset(-3 * margin);
        make.bottom.equalTo(weakSelf.topView).offset(-3 * margin);
    }];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.topView.mas_bottom);
        make.left.right.equalTo(weakSelf.view);
        make.bottom.equalTo(weakSelf.mas_bottomLayoutGuideTop);
    }];
    
}

@end
